package com.hzcx.app.simplechat.model;

import android.content.Context;

import com.hzcx.app.simplechat.api.APIRequest;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.api.RxHelper;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.chat.bean.ChatCustomServiceMenuBean;
import com.hzcx.app.simplechat.ui.chat.bean.ChatBottomAssistantMenuBean;
import com.hzcx.app.simplechat.ui.chat.bean.ChatHistoryBean;
import com.hzcx.app.simplechat.ui.chat.bean.ChatQuickMsgBean;
import com.hzcx.app.simplechat.util.token.TokenUtils;

import java.util.List;

/**
 * 聊天界面想关
 */
public class ChatModel {

    /**
     * 获取快捷回复列表
     *
     * @param context
     * @param observer
     */
    public static void getChatQuickMsgList(Context context, BaseObserver<List<ChatQuickMsgBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getChatQuickMsgList(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 添加快捷回复
     *
     * @param context
     * @param maincontent
     * @param reply_id
     * @param observer
     */
    public static void addChatQucikMsg(Context context, String maincontent, String reply_id, String reply_images, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .addChatQucikMsg(TokenUtils.getTokenHeader(), maincontent, reply_id, reply_images)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 删除快捷回复
     *
     * @param context
     * @param reply_id
     * @param observer
     */
    public static void deleteChatQuickMsg(Context context, int reply_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .deleteChatQuickMsg(TokenUtils.getTokenHeader(), reply_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 快捷回复排序
     *
     * @param context
     * @param reply_ids
     * @param observer
     */
    public static void moveChatQuickMsg(Context context, String reply_ids, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .moveChatQuickMsg(TokenUtils.getTokenHeader(), reply_ids)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 给官方客服发消息
     *
     * @param context
     * @param observer
     */
    public static void sendCustomServiceMsg(Context context, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .sendCustomServiceMsg(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 获取官方底部菜单
     *
     * @param context
     * @param observer
     */
    public static void getChatBottomAssistantMenu(Context context, BaseObserver<List<ChatBottomAssistantMenuBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getChatBottomAssistantMenu(TokenUtils.getTokenHeader())
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 根据菜单ID获取官方消息
     *
     * @param context
     * @param type
     * @param push_id
     * @param observer
     */
    public static void getChatAssistantMessage(Context context, String type, int push_id, BaseObserver<BaseEmptyBean> observer) {
        APIRequest
                .getRequestInterface()
                .getChatAssistantMessage(TokenUtils.getTokenHeader(), type, push_id)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }

    /**
     * 从服务端获取消息记录
     *
     * @param context
     * @param id
     * @param msgId
     * @param observer
     */
    public static void getChatHistory(Context context, int id, String msgId, BaseObserver<List<ChatHistoryBean>> observer) {
        APIRequest
                .getRequestInterface()
                .getChatHistory(TokenUtils.getTokenHeader(), id, msgId)
                .compose(RxHelper.observableIO2Main(context))
                .subscribe(observer);
    }
}
